//package com.shopoo.authorization.app.provider;
//
//import com.alibaba.fastjson.JSON;
//import jakarta.annotation.Resource;
//
//import org.springframework.security.authentication.AuthenticationProvider;
//import org.springframework.security.authentication.BadCredentialsException;
//import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
//import org.springframework.security.core.Authentication;
//import org.springframework.security.core.AuthenticationException;
//import org.springframework.security.core.userdetails.UserDetails;
//import org.springframework.security.core.userdetails.UserDetailsService;
//import org.springframework.security.crypto.password.PasswordEncoder;
//
///**
// *
// * @Author <a href="mailto:android_li@sina.cn">MaoYuan.Li</a>
// * @Date 2023/1/14 21:20
// */
//public class AdminPwdAuthenticationProvider implements AuthenticationProvider {
//
//	@Resource
//	private UserDetailsService userDetailsService;
//
//	@Resource
//	private PasswordEncoder passwordEncoder;
//
//	//认证方法
//	@Override
//	public Authentication authenticate(Authentication authentication) throws AuthenticationException {
//		UsernamePasswordAuthenticationToken adminLoginToken = (UsernamePasswordAuthenticationToken) authentication;
//		System.out.println("===进入Admin密码登录验证环节====="+ JSON.toJSONString(adminLoginToken));
//		UserDetails userDetails = userDetailsService.loadUserByUsername(adminLoginToken.getName());
//		//matches方法，前面为明文，后续为加密后密文
//		//匹配密码。进行密码校验
//		if(passwordEncoder.matches(authentication.getCredentials().toString(),userDetails.getPassword())){
//			return  new UsernamePasswordAuthenticationToken(userDetails, userDetails.getPassword(), userDetails.getAuthorities());
//		}
//		throw new BadCredentialsException("用户名密码不正确");
//	}
//	@Override
//	public boolean supports(Class<?> authentication) {
//		return UsernamePasswordAuthenticationToken.class.isAssignableFrom(authentication);
//	}
//}
